package cn.mapway.plugin.db;

import com.squareup.javapoet.ClassName;
import org.nutz.lang.Strings;

import java.util.HashMap;
import java.util.Map;

/**
 * DataTypeMapper
 *
 * @author zhangjianshe zhangjianshe@gmail.com
 */
public class DataTypeMapper {
    private static final Map<String, Class> globalMapper;

    static {
        globalMapper = new HashMap<>();
        globalMapper.put("polygon", org.postgresql.geometric.PGpolygon.class);
        globalMapper.put("box", org.postgresql.geometric.PGbox.class);
        globalMapper.put("circle", org.postgresql.geometric.PGcircle.class);
        globalMapper.put("point", org.postgresql.geometric.PGpoint.class);
        globalMapper.put("line", org.postgresql.geometric.PGline.class);
        globalMapper.put("lseg", org.postgresql.geometric.PGlseg.class);
        globalMapper.put("path", org.postgresql.geometric.PGpath.class);


    }

    public final static Class resolve(String dt) {
        if (Strings.isBlank(dt)) {
            return null;
        }
        String temp = dt.toLowerCase();
        Class t = globalMapper.get(temp);
        return t;
    }
}
